#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define MAXWORD 100

#define BUFSIZE 100
char buf[BUFSIZE];
int bufp = 0;
int getch(void)
{
    return (bufp > 0) ? buf[--bufp] : getchar();
}
void ungetch(int c)
{
    if(bufp >= BUFSIZE)
        printf("ungetch: too many characters\n");
    else
    {
        buf[bufp++] = c;
    }    
}

int getword(char *word, int lim)
{
    char *w = word;
    char c;

    do{
        c = getch();
    }
    while (isspace(c));

    if(c != EOF){
        *w++ = c;
    }
    if(!isalpha(c) && c != '_' && c != '#' && c != '"'){
        *w = '\0';
        return c;               
    }

    for(; --lim > 0; w++){
        *w = getch();
  
        if(!isalnum(*w) && *w != '_' && *w != '"'){
            ungetch(*w);
            break;
        }        
    }
    *w = '\0';
    return word[0];
}

int main(int argc, char* argv[])
{
    char word[MAXWORD];
    while (getword(word, MAXWORD) != EOF)
    {
        printf("%s\n", word);
    }
    
    return 0;
}